<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div class="main-content">
    <div class="box box-main">
        <form id="facilityCatForm" model="post" action="<c:url value="/web/admin/facilityCat/executeFacilityCatEdit.action"/>" method="post" class="form-horizontal">
            <div class="box-body">
                <input type="hidden" name="id" value="${facilityCat.id}"/>
                <input type="hidden" name="systemUserId" value="${facilityCat.systemUserId}"/>
                <input type="hidden" name="systemUserName" value="${facilityCat.systemUserName}"/>
                <input type="hidden" name="createDate" value="${facilityCat.createDate}"/>
                <div class="row">
                    <c:if test="${facilityCat.id!=null}">
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="control-label col-sm-4" title="">
                                    ID：<i class="fa icon-question hide"></i></label>
                                <div class="col-sm-8">
                                    <span>${facilityCat.id}</span>
                                </div>
                            </div>
                        </div>
                    </c:if>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required ">*</span> 类型名称：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="catName" name="catName" value="${facilityCat.catName}" maxlength="100" class="form-control required ">
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                类型描述：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="description" name="description" value="${facilityCat.description}" maxlength="100" class="form-control ">
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                上级类型：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="selectParentId" id="selectParentId" name="selectParentId" class="form-control">
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                所属企业：<i class="fa icon-question hide"></i></label>
                            <label class="control-label col-sm-8" style="text-align: left" title="">
                                ${enterprise.enterpriseName}<i class="fa icon-question hide"></i></label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-footer">
                <div class="row">
                    <div class="col-sm-offset-2 col-sm-12">
                        <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>&nbsp;

                        <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="closeView()"><i class="fa fa-times"></i> 关 闭</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $("#facilityCatForm").validate({
        submitHandler: function(form){
            js.ajaxSubmitForm($(form), function(data){
                js.showMessage(data.msg);
                if(data.status == Global.NO){
                    closeView();
                    $('#dataGrid').dataGrid("refresh");
                }
            }, "json");
        }
    });

    var selectParentId = $('#selectParentId').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/admin/facilityCat/getFacilityCatSelect.action?id=${facilityCat.parentId}" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        required: true,
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${facilityCat.parentId}')
    });

    function closeView() {
        layer.close(LayWin['wFacility']);
    }
</script>


